package com.tianhui.consignortwofei.pattern.orderOprate.impl;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.fgs.common.utils.TipDialogUtil;
import com.fgs.common.utils.ToastUtil;
import com.tianhui.consignortwofei.constant.KeyValue;
import com.tianhui.consignortwofei.constant.OrderType;
import com.tianhui.consignortwofei.mvp.model.enty.OrderOperateInfo;
import com.tianhui.consignortwofei.mvp.ui.activity.OrderAdjustActivity;
import com.tianhui.consignortwofei.pattern.orderOprate.IOrderOperate;

/**
 * @author fgs
 * @date 2020/8/29
 * @description 确认交货
 **/
public class DeliveryConfirmOperate implements IOrderOperate {
    @Override
    public void orderOperate(Context context, OrderOperateInfo operateInfo) {
        //1.司机未交货，不可以确认交货
        //2.司机交货后，isrecelve == 0时，可以确认交货 isrecelve == 1时，提示已确认交货
        //3.订单取消时，不可确认交货
        if (operateInfo != null && operateInfo.orderInfo != null) {
            if (operateInfo.orderInfo.isstate < 9) {
//                TipDialogUtil.showTipDialog(context, "订单未完成，不可确认交货重量");
                TipDialogUtil.showTipDialog(context, "当前司机没有上传卸车车辆照片、卸车单据照片，无法确认收货，请联系司机上传");
            } else if (operateInfo.orderInfo.isstate == 9) {
                if (operateInfo.orderInfo.isrecelve == 0) {
                    Bundle bundle = new Bundle();
                    bundle.putParcelable(KeyValue.KEY_ORDER_INFO, operateInfo.orderInfo);
                    bundle.putInt(KeyValue.KEY_TYPE, OrderType.TYPE_DELIVER_CONFIRM);
                    Intent intent = new Intent(context, OrderAdjustActivity.class);
                    intent.putExtras(bundle);
                    context.startActivity(intent);
                } else {
                    TipDialogUtil.showTipDialog(context, "您已确认交货，无需再次确认交货");
                }
            } else {

                if (operateInfo.orderInfo.isrecelve == 0) {
                    TipDialogUtil.showTipDialog(context, "该订单当前无法确认交货");
                } else {
                    TipDialogUtil.showTipDialog(context, "您已确认交货，无需再次确认交货");
                }

            }
        } else {
            ToastUtil.showShortToast("获取订单信息失败");
        }

    }


//    @Override
//    public void orderOperate(Context context, OrderOperateInfo operateInfo, OrderOperateCallback orderOperateCallback) {
//        ToastUtil.showLongToast(operateInfo.operate);
//    }
}
